package com.xie.smfs.entity;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;

public class UntouchableGhostEntity extends GhostEntity {

    public UntouchableGhostEntity(EntityType<? extends GhostEntity> entityType, World world) {
        super(entityType, world, false, 0, 32.0);
        this.ghostLevel = 2; // B级恐怖等级
    }

    @Override
    public boolean damage(DamageSource source, float amount) {
        // 检查攻击者是否为玩家
        if (source.getAttacker() instanceof PlayerEntity) {
            PlayerEntity player = (PlayerEntity) source.getAttacker();
            // 施加凋零V效果，持续120秒（2400 ticks）
            player.addStatusEffect(new StatusEffectInstance(
                StatusEffects.WITHER, 
                120 * 20, // 120秒
                4, // 等级5（V）
                false, 
                false, 
                true
            ));
            return false; // 阻止伤害
        }
        return super.damage(source, amount);
    }

    @Override
    public void tick() {
        super.tick();
        // 可以添加其他逻辑，如移动或视觉效果
    }
}